﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

////#pragma once

#include "GmFamilyService.h"
#include "IFamilyEntity.h"
#include "ElementCreationOptions.h"

namespace gcmp
{
    enum class ElementCreationOptions;
    enum class ProjectReferenceTypeOfReferenceLine;
}

namespace gfam
{
    enum class ReferenceLineTypes;

    class GM_FAMILY_SERVICE_EXPORT IFamilyReferenceLine : public IFamilyEntity
    {
        DEFINE_CAST_DERIVED(gfam::IFamilyReferenceLine, gfam::IFamilyEntity)
    public:
        /// \brief 创建直线参照线
        /// 
        /// \param pDoc 文档指针
        /// \param planeId 工作平面Id
        /// \param startPt 起点
        /// \param endPt 终点
        /// \param eco 创建选项
        /// \return 返回创建的参照线
        static IFamilyReferenceLine* CreateAsStraightLine(gcmp::IDocument* pDoc, const gcmp::ElementId& planeId, const gcmp::Vector3d& startPt, const gcmp::Vector3d& endPt, gcmp::ElementCreationOptions eco = gcmp::ElementCreationOptions::Normal);

        /// \brief 三点创建圆弧参照线
        /// 
        /// \param pDoc 文档指针
        /// \param startPt 起点
        /// \param endPt 终点
        /// \param onArcPt 圆弧上其他点
        /// \param eco 创建选项
        /// \return 返回创建的参照线
        static IFamilyReferenceLine* CreateAsArcByThreePoints(gcmp::IDocument* pDoc, const gcmp::ElementId& planeId, const gcmp::Vector3d& startPt, const gcmp::Vector3d& endPt, const gcmp::Vector3d& onArcPt, gcmp::ElementCreationOptions eco = gcmp::ElementCreationOptions::Normal);

        /// \brief 创建圆弧参照线
        /// 
        /// \param pDoc 文档指针
        /// \param planeId 工作平面Id
        /// \param centerPt 圆心
        /// \param startPt 起点
        /// \param endPt 终点
        /// \param eco 创建选项
        /// \return 返回创建的参照线
        static IFamilyReferenceLine* CreateAsArcByCenterEnd(gcmp::IDocument* pDoc, const gcmp::ElementId& planeId, const gcmp::Vector3d& centerPt, const gcmp::Vector3d& startPt, const gcmp::Vector3d& endPt, gcmp::ElementCreationOptions eco = gcmp::ElementCreationOptions::Normal);

        /// \brief 创建圆弧参照线
        /// 
        /// \param pDoc 文档指针
        /// \param planeId 工作平面Id
        /// \param centerPt 圆心
        /// \param startPt 起点
        /// \param endPt 终点
        /// \param bSignClock 顺逆方向，1：逆时， -1：顺时
        /// \param eco 创建选项
        /// \return 返回创建的参照线
        //原CreateAsArcByCenterEnd内部无法通过 centerPt startPt endPt方式无法计算bSignClock，故添加此函数。在外部计算bSignClock，传入函数
        static IFamilyReferenceLine* CreateAsArcByCenterEnd(gcmp::IDocument* pDoc, const gcmp::ElementId& planeId, const gcmp::Vector3d& centerPt, const gcmp::Vector3d& startPt, const gcmp::Vector3d& endPt, bool bSignClock, gcmp::ElementCreationOptions eco = gcmp::ElementCreationOptions::Normal);

        /// \brief 创建圆弧参照线
        /// 
        /// \param pDoc 文档指针
        /// \param planeId 工作平面Id
        /// \param centerPt 圆心
        /// \param startPt 起点
        /// \param radius 半径
        /// \param startAngle 起始角度
        /// \param endAngle 终止角度
        /// \param bSignClock 顺逆方向，1：逆时， -1：顺时
        /// \param eco 创建选项
        /// \return 返回创建的参照线
        static IFamilyReferenceLine* CreateAsArcByAngle(gcmp::IDocument* pDoc, const gcmp::ElementId& planeId, const gcmp::Vector3d& centerPt, double radius, double startAngle, double endAngle, int nClockSign, gcmp::ElementCreationOptions eco = gcmp::ElementCreationOptions::Normal);

        /// \brief 获取Implementation Uid
        ///
        /// \return UniIdentity 返回ImplementationUid
        static gcmp::UniIdentity GetImplementationUid();


        /// \brief 获得SketchId
        ///
        /// \return 获取的SketchId
        virtual gcmp::ElementId GetSketchId() const = 0;

        /// \brief 设置SketchId
        ///
        /// \param id SketchId
        /// \return bool 设置成功返回true，否则返回false
        virtual bool SetSketchId(const gcmp::ElementId& id) = 0;

        /// \brief 获取是否关联平面
        ///
        /// \return bool 关联平面返回true，否则返回false
        virtual bool GetIsLinkedWithPlane() const = 0;

        /// \brief 设置是否关联平面
        ///
        /// \param bIsLinked 是否关联平面
        /// \return bool 成功返回true 失败返回false
        virtual bool SetIsLinkedWithPlane(bool bIsLinked) = 0;

        /// \brief 设置圆心是否可见
        ///
        /// \param bVisible 是否可见
        /// \return bool 成功返回true 失败返回false
        virtual bool SetArcCenterVisible(bool bVisible) = 0;

        /// \brief 获取圆心是否可见
        ///
        /// \return bool 圆心可见返回true，否则返回false
        virtual bool GetArcCenterVisible() const = 0;

        /// \brief 获取圆心
        ///
        /// \return Vector3d 获取到的圆心
        virtual gcmp::Vector3d GetCenter()const = 0;

        /// \brief 获取中点
        ///
        /// \return Vector3d 获取到的中点
        virtual gcmp::Vector3d GetMiddlePoint() const = 0;

        /// \brief 获取起点
        ///
        /// \return Vector3d 获取到的起点
        virtual gcmp::Vector3d GetStartPoint() const = 0;

        /// \brief 获取终点
        ///
        /// \return Vector3d 获取到的终点
        virtual gcmp::Vector3d GetEndPoint() const = 0;

        /// \brief 获取起始角度
        ///
        /// \return double 获取到的起始角度
        virtual double GetStartAngle() const = 0;

        /// \brief 获取终止角度
        ///
        /// \return double 获取到的终止角度
        virtual double GetEndAngle() const = 0;

        /// \brief 获取坐标系
        ///
        /// \return Coordinate3d 获取到的坐标系
        virtual gcmp::Coordinate3d GetBaseCoord() const = 0;

        /// \brief 获取三维曲线
        ///
        /// \return OwnerPtr<gcmp::IGraphicsCurve3d> 获取到的三维曲线
        virtual gcmp::OwnerPtr<gcmp::IGraphicsCurve3d> GetCurve() const = 0;

        /// \brief 设置三维曲线
        ///
        /// \param OwnerPtr<gcmp::IGraphicsCurve3d> 三维曲线
        /// \return void
        virtual void SetCurve(gcmp::OwnerPtr<gcmp::IGraphicsCurve3d> upGCurve) = 0;

        /// \brief 获取参照线项目参照类型
        ///
        /// \return ProjectReferenceTypeOfReferenceLine 参照线项目参照类型
        virtual gcmp::ProjectReferenceTypeOfReferenceLine GetProjectReferenceType() const = 0;

        /// \brief 设置参照线项目参照类型
        ///
        /// \param nType 参照线项目参照类型
        /// \return bool 成功返回true 失败返回false
        virtual bool SetProjectReferenceType(gcmp::ProjectReferenceTypeOfReferenceLine nType) = 0;

        /// \brief 获取参照线类型
        ///
        /// \return ReferenceLineTypes 获取参照线类型
        virtual ReferenceLineTypes GetReferenceLineType() const = 0;

        /// \brief 设置参照线类型
        ///
        /// \param type 参照线类型
        /// \return bool 成功返回true 失败返回false
        virtual bool SetReferenceLineType(ReferenceLineTypes type) = 0;

        /// \brief 获取是否为直线
        ///
        /// \return bool 直线返回true，否则返回false
        virtual bool IsStraightLine() const = 0;

        /// \brief 获取是否为圆弧
        ///
        /// \return bool 圆弧返回true，否则返回false
        virtual bool IsArc() const = 0;

        /// \brief 获取是否为圆
        ///
        /// \return bool 圆返回true，否则返回false
        virtual bool IsCircle() const = 0;

        /// \brief 设置关联平面
        ///
        /// \param refPlaneToLock 关联平面Id
        /// \return bool 成功返回true 失败返回false
        virtual bool SetLockedPlaneId(const gcmp::ElementId& refPlaneToLock) = 0;

        /// \brief 获取关联平面Id
        ///
        /// \return ElementId 关联平面Id
        virtual gcmp::ElementId GetLockedPlaneId() const = 0;

        /// \brief 取消关联平面
        ///
        /// \return bool 成功返回true 失败返回false
        virtual bool UnlockFromPlane() = 0;

        ///为了web版编译通过，增加的方法
        /// \brief 获取关联平面Id
        ///
        /// \return ElementId 关联平面Id
        virtual gcmp::ElementId GetAssociatedPlaneId() const = 0;

        /// \brief 设置关联平面
        ///
        /// \param value 关联平面Id
        /// \return bool 成功返回true 失败返回false
        virtual bool SetAssociatedPlaneId(const gcmp::ElementId& value) = 0;

        /// \brief 获取ElementId
        ///
        /// \return ElementId 获取到的ElementId
        virtual gcmp::ElementId GetOwnerElementId() const = 0;

        /// \brief 设置主对象的Id
        /// 主对象指具有强依赖关系的对象，当主对象被删除时，从对象也会被删除。
        ///
        /// \param masterId 主对象Id
        /// \return void
        virtual void SetMasterId(gcmp::ElementId masterId) = 0;

        /// \brief 获取约束解算曲线
        ///
        /// \return 约束解算曲线
        virtual const gcmp::IGraphicsCurve3d* GetGCurveForSolve() const = 0;

        /// \brief 获取约束解算曲线
        ///
        /// \return 约束解算曲线
        virtual gcmp::IGraphicsCurve3d* GetGCurveForSolveFW() = 0;

        /// \brief 设置约束解算曲线
        ///
        /// \param pCurve 约束解算曲线
        /// \return void
        virtual void SetGCurveForSolve(const gcmp::IGraphicsCurve3d* pCurve) = 0;

    };

}